{extend name="public/edit" /}

{block name="content"}
{if $data['type']==1}
<div class="layui-form-item">
    <label class="layui-form-label">轮播图片</label>
    <div class="layui-input-block">
        <div class="layui-upload">
            <button type="button" name="img" number="1" class="layui-btn form-file-pic">选择文件</button>
            <div class="layui-upload-list">
                {if $data['img']}
                <div class="myimg">
                    <div class="imgcon">
                        <img src="{$data['img']}" class="layui-upload-img" style="width: 100px;height: 100px;"
                            id="test-upload-normal-s">
                    </div>
                    <div style="width: 100px;margin-top: 5px;line-height: 17.13px;" class="layui-btn layui-btn-danger layui-btn-xs form-file-del"><i
                            class="layui-icon"></i></div>
                </div>
                {/if}
            </div>
            
        </div>
    </div>
</div>
{else/}
<div class="layui-form-item layui-form-text content" >
        <label class="layui-form-label">文章内容</label>
        <div class="layui-input-block">
            {:get_um('content',$data['content'])}
        </div>
</div> 
{/if}   
<div class="layui-form-item layui-form-text">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="sort" value="{$data['sort']}" lay-verify="required|number" placeholder="点此请输入" autocomplete="off" class="layui-input">
        </div>
</div> 
<div class="layui-form-item">
    <label class="layui-form-label">是否设置为背景</label>
    <div class="layui-input-block">
        <input type="radio" name="is_back"  lay-verify="required"  autocomplete="off"  value="1" title="是"  {$data['is_back'] == 1 ? 'checked' : ''}
            class="layui-input">

        <input type="radio" name="is_back" lay-verify="required"  autocomplete="off" title="否" value="0" {$data['is_back'] == 0 ? 'checked' : ''}
            class="layui-input">   
    </div>
</div> 
<div class="layui-form-item">
    <label class="layui-form-label">是否显示</label>
    <div class="layui-input-block">
        <input type="radio" name="slide_show"  lay-verify="required"  autocomplete="off"  value="1" title="是"  {$data['slide_show'] == 1 ? 'checked' : ''}
            class="layui-input">

        <input type="radio" name="slide_show" lay-verify="required"  autocomplete="off" title="否" value="0" {$data['slide_show'] == 0 ? 'checked' : ''}
            class="layui-input">   
    </div>
</div>

{/block}

{block name="script"}
<script>
   
   views.verify(false).func(function(form,admin,upload,laydate){
        upload.render({
            elem: '#test-upload-normal'
            ,url: '/api/upload/'
            ,auto: false //选择文件后不自动上传
            ,bindAction: '' //指向一个按钮触发上传
            ,size:'1024'
            ,choose: function(obj){
                //将每次选择的文件追加到文件队列
                var files = obj.pushFile();
                
                //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
                obj.preview(function(index, file, result){
                    // console.log(index); //得到文件索引
                    layui.$('#test-upload-normal-s').attr('src',result);
                    layui.$('input[name="pic"]').val(result)
                    layui.$('input[name="agency_life_shop_pic"]').val(file.name)
                });
            }
        });      
    }).get();
</script>
{/block}